﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加用户</title>
<link href="${pageContext.request.contextPath}/css/themes/default/easyui.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath}/css/themes/icon.css" rel="stylesheet"></link>
<link href="${pageContext.request.contextPath}/css/themes/color.css" rel="stylesheet" />
<script src="${pageContext.request.contextPath}/script/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/script/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/script/easyui-lang-zh_CN.js"></script>
<style>
body {
	font-size: 12px;
	overflow-y: hidden;
}

th {
	font-size: 20px;
}

td {
	font-size: 18px;
}
</style>
</head>
<body class="easyui-layout" onload="initContent()" >
	<div data-options="region:'center'" >
		<div class="easyui-tabs" data-options="fit:true" >
			<div title="添加用户" style="padding:10px;">
				<form id="f" style="margin-top:4%;margin-left: 35%;">
					<tr>
						<td><img src="${pageContext.request.contextPath}/css/themes/icons/man.png" />
							用户名：<input class="easyui-textbox" type="text" id="username" name="username"
							style="width:200px" data-options="required:true,missingMessage:'用户名必填!'" /></td>
					</tr>
					</br>
					</br>
					<tr>
						<td><img src="${pageContext.request.contextPath}/css/themes/icons/lock.png" />
							密&nbsp;&nbsp;码：<input class="easyui-textbox" type="text" id="password"
							name="password" style="width:200px" data-options="required:true,missingMessage:'密码必填!'" />
						</td>
					</tr>
					</br>
					</br>
					<tr>
						<td><img src="${pageContext.request.contextPath}/images/telephone.png" />
							电&nbsp;&nbsp;话：<input class="easyui-textbox" type="text" id="telephone"
							name="telephone" style="width:200px" data-options="required:true,missingMessage:'电话必填!'" />
						</td>
					</tr>
					</br>
					</br>
					<tr>
						<img src="${pageContext.request.contextPath}/css/themes/icons/sum.png" />
						<td>性&nbsp;&nbsp;别：</td>
						<td><label><input type="radio" id="sex" name="sex" value="男">男</label>&emsp;&emsp;
							<label><input type="radio" id="sex" name="sex" value="女">女</label>
						</td>
					</tr>
					</br>
					</br>
					<tr>
						<img src="${pageContext.request.contextPath}/css/themes/icons/r.gif" />
						姓&nbsp;&nbsp;名：
						<input class="easyui-textbox" type="text" name="nickname" id="nickname"
							style="width:200px" data-options="required:true,missingMessage:'姓名必填!'" />
					</tr>
					</br>
					</br>
					<tr>
						<img src="${pageContext.request.contextPath}/images/ress.png" />
						地&nbsp;&nbsp;址：
						<input class="easyui-textbox" type="text" name="cydz" id="cydz"
							style="width:200px" data-options="required:true,missingMessage:'地址必填!'" />
					</tr>
					</br>
					</br>
					<tr>
						<td>&emsp;&emsp;&emsp;&emsp;
						<input onclick="cz()" class="easyui-linkbutton c1" style="width:50px;height: 30px;margin-left: 3%;" value="重置"/>
						</td>
						<td>&emsp;&emsp;&emsp;
 						<input type="button" class="easyui-linkbutton c1" style="width:50px;height: 30px;" onclick="adduser()" value="注册"/>
						</td>
					</tr>
				</form>
			</div>
		</div>
	</div>
	
	<script>
		function cz(){
			window.location.reload();
		}
		
		function adduser(){
        	var formData = new FormData($("#f")[0]);
        	var username=$("#username").val();
        	var password=$("#password").val();
        	var telephone=$("#telephone").val();
				$.ajax({
					url:"${pageContext.request.contextPath}/admin/adminadduser",
					type:"POST",				
					data:formData,
					dataType:"json",
					async: false,
	                cache: false,
	                contentType: false,
	                processData: false,	
					success:function(data){
       				 	alert("注册成功！！！");
						window.location.href="${pageContext.request.contextPath}/lodinguser.html";
					},
					error:function(){
					if(username.length<3 || username.length>5){
						alert("用户名格式错了！");
					}
					if(password.length<6 || password.length>8){
						alert("密码格式错了！");
					}
					if(telephone.length!=11){
						alert("手机号码格式错了！");
					}else
						alert("用户名已被占用，注册失败！！！");
					}
				});
			}
	</script>
</body>
</html>
